﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrintConverter
{
    public class Module : INotifyPropertyChanged
    {
        private int? _dpiX, _dpiY;
        private int? _mm, _perInch, _point;
        private Orientation _orientation;
        private Style _style;

        public event PropertyChangedEventHandler PropertyChanged;

        public Module()
        {
            DpiX = DpiY = 600;
            IsHorizontal = true;
            IsMM = true;
        }

        public int? DpiX
        {
            get
            {
                return _dpiX;
            }

            set
            {
                _dpiX = value;
                RaisePropertyChanged("DpiX");
            }
        }

        public int? DpiY
        {
            get
            {
                return _dpiY;
            }

            set
            {
                _dpiY = value;
                RaisePropertyChanged("DpiY");
            }
        }

        public int? MM
        {
            get
            {
                return _mm;
            }

            set
            {
                _mm = value;
                RaisePropertyChanged("MM");
            }
        }

        public int? Inch
        {
            get
            {
                return _perInch;
            }

            set
            {
                _perInch = value;
                RaisePropertyChanged("Inch");
            }
        }

        public int? Point
        {
            get
            {
                return _point;
            }

            set
            {
                _point = value;
                RaisePropertyChanged("Point");
            }
        }

        public bool IsHorizontal
        {
            get
            {
                return _orientation == Orientation.Horizontal;
            }

            set
            {
                if (value)
                {
                    _orientation = Orientation.Horizontal;
                    IsVertical = false;
                }
                RaisePropertyChanged("IsHorizontal");
            }
        }

        public bool IsVertical
        {
            get
            {
                return _orientation == Orientation.Vertical;
            }

            set
            {
                if (value)
                {
                    _orientation = Orientation.Vertical;
                    IsHorizontal = false;
                }
                RaisePropertyChanged("IsVertical");
            }
        }

        public bool IsMM
        {
            get
            {
                return _style == Style.MM;
            }

            set
            {
                if (value)
                {
                    _style = Style.MM;
                    IsInch = false;
                    IsPoint = false;
                }
                RaisePropertyChanged("IsMM");
            }
        }

        public bool IsInch
        {
            get
            {
                return _style == Style.Inch;
            }
            set
            {
                if (value)
                {
                    _style = Style.Inch;
                    IsMM = false;
                    IsPoint = false;
                }
                RaisePropertyChanged("IsInch");
            }
        }

        public bool IsPoint
        {
            get
            {
                return _style == Style.Point;
            }

            set
            {
                if (value)
                {
                    _style = Style.Point;
                    IsMM = false;
                    IsInch = false;
                }
                RaisePropertyChanged("IsPoint");
            }
        }

        private void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        private enum Orientation
        {
            Horizontal,
            Vertical
        }

        private enum Style
        {
            MM,
            Inch,
            Point
        }
    }
}
